import json



def replace_urls(data):
    for item in data:
        screen_name = item['screen_name']
        companyId = item['companyId']
        if '互联网汇聚' in screen_name:
            item['screen_url'] = f"https://xxxx/newsproduction?companyId={companyId}&userId=E1951D62616149C4A00E5BCB34643EE9&province=云南&city=昆明&appCode=QMTNRK_YUNSHI"
        elif '新闻生产' in screen_name:
            item['screen_url'] = f"https://xxxx/newsproduction?companyId={companyId}&userId=E1951D62616149C4A00E5BCB34643EE9&appCode=QMTNRK_YUNSHI"
        elif '发布数据' in screen_name:
            item['screen_url'] = f"https://xxxx/newsproduction?companyId={companyId}&userId=E1951D62616149C4A00E5BCB34643EE9&appCode=QMTNRK_YUNSHI"
        elif '选题策划' in screen_name:
            item['screen_url'] = f"https://xxxx/newsproduction?companyId={companyId}&userId=E1951D62616149C4A00E5BCB34643EE9&appCode=YDD_YUNSHI"
        else:
            # 可选：如果有其他情况需要处理，您可以在此处添加逻辑
            pass
    return data


# 读取 JSON 文件
with open('/Users/xxxx/Downloads/output.json', 'r', encoding='utf-8') as file:
    json_data = json.load(file)

# 调用函数进行替换
updated_data = replace_urls(json_data)

# 将更新后的数据写入新的 JSON 文件中
with open('/Users/xxxx/Documents/updated_json_file.json', 'w', encoding='utf-8') as file:
    json.dump(updated_data, file, ensure_ascii=False, indent=4)

print("数据已写入到 updated_json_file.json 文件中。")




